#define _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>
int is_leap_year(int y)
{
    if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
    {
        return 1;
    }
    return 0;
}
int main() {
    int y = 0;
    int m = 0;
    int r = 0;
    scanf("%d%d%d", &y, &m, &r);
    int arr[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    int i = 0;
    int day = 0;
    for (i = 0; i < m - 1; i++)
    {
        day += arr[i];
    }
    day += r;
    if (is_leap_year(y) == 1 && m > 2)
    {
        day += 1;
    }
    printf("%d", day);
    return 0;
}